import echarts from 'echarts'
import * as util from './util'

const borderColor = '#005792'
const fontColor = '#666666'

const defaultOption = {
  title: {
    show: false,
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  color: util.COLOR
}

class Echarts {
  constructor (dom) {
    this.dom = dom
    this.instance = echarts.init(dom)
  }

  line (option) {
    const defaultOption = {

    }
    return this.instance
  }

  bar (option) {
    const defaultOption = {
      title: {
        show: false,
      },
      color: util.COLOR,
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
    }
    option = util.extend(true, {}, defaultOption, option)
    this.instance.setOption(option)
    return this.instance
  }

  pie (option) {
    const defaultOption = {
      title: {
        show: false,
      },
      color: util.COLOR
    }
    return this.instance
  }

  showLoading () {
    this.instance.showLoading(...arguments)
  }

  hideLoading () {
    this.instance.hideLoading(...arguments)
  }

  setOption (option, ...rest) {
    this.instance.setOption(option, ...rest)
  }
}

export default Echarts
